﻿using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask;

namespace NazTek.Documenter.Ssis.Control.Tasks
{
    internal class SsisSql : SsisTaskBase
    {
        public override string Documentation
        {
            get
            {
                var doc = new StringBuilder(string.Format(
                    "<li>{0} [{1}]<br>Connection: {2}<br><pre><code>{3}</code></pre></li>",
                    Name, Description, Component.Connection,
                    Component.SqlStatementSource.Replace("\n", "<br>").TrimEnd("<br>".ToCharArray())));
                return doc.ToString();
            }
        }

        internal SsisSql(TaskHost component)
        {
            Name = component.Name;
            Description = component.Description;
            Component = (IDTSExecuteSQL)component.InnerObject;
        }

        private IDTSExecuteSQL Component { get; set; }
    }
}